home *** CD-ROM | disk | FTP | other *** search
/ Almathera Ten Pack 1: Comms & Networking / Almathera Ten on Ten - Disc 1: Comms & Networking.iso / amiga-useful / perl / src / perl.h < prev    next >
C/C++ Source or Header  |  1995-05-04  |  24KB  |  1,110 lines

  1. /* $RCSfile: perl.h,v $$Revision: 4.0.1.6 $$Date: 92/06/08 14:55:10 $
  2.  *
  3.  *    Copyright (c) 1991, Larry Wall
  4.  *
  5.  *    You may distribute under the terms of either the GNU General Public
  6.  *    License or the Artistic License, as specified in the README file.
  7.  *
  8.  * $Log:    perl.h,v $
  9.  * Revision 4.0.1.6  92/06/08  14:55:10  lwall
  10.  * patch20: added Atari ST portability
  11.  * patch20: bcopy() and memcpy() now tested for overlap safety
  12.  * patch20: Perl now distinguishes overlapped copies from non-overlapped
  13.  * patch20: removed implicit int declarations on functions
  14.  * 
  15.  * Revision 4.0.1.5  91/11/11  16:41:07  lwall
  16.  * patch19: uts wrongly defines S_ISDIR() et al
  17.  * patch19: too many preprocessors can't expand a macro right in #if
  18.  * patch19: added little-endian pack/unpack options
  19.  * 
  20.  * Revision 4.0.1.4  91/11/05  18:06:10  lwall
  21.  * patch11: various portability fixes
  22.  * patch11: added support for dbz
  23.  * patch11: added some support for 64-bit integers
  24.  * patch11: hex() didn't understand leading 0x
  25.  * 
  26.  * Revision 4.0.1.3  91/06/10  01:25:10  lwall
  27.  * patch10: certain pattern optimizations were botched
  28.  * 
  29.  * Revision 4.0.1.2  91/06/07  11:28:33  lwall
  30.  * patch4: new copyright notice
  31.  * patch4: made some allowances for "semi-standard" C
  32.  * patch4: many, many itty-bitty portability fixes
  33.  * 
  34.  * Revision 4.0.1.1  91/04/11  17:49:51  lwall
  35.  * patch1: hopefully straightened out some of the Xenix mess
  36.  * 
  37.  * Revision 4.0  91/03/20  01:37:56  lwall
  38.  * 4.0 baseline.
  39.  * 
  40.  */
  41.  
  42. #define VOIDWANT 1
  43. #include "config.h"
  44.  
  45. #ifdef MYMALLOC
  46. #   ifdef HIDEMYMALLOC
  47. #    define malloc Mymalloc
  48. #    define realloc Myremalloc
  49. #    define free Myfree
  50. #   endif
  51. #   define safemalloc malloc
  52. #   define saferealloc realloc
  53. #   define safefree free
  54. #endif
  55.  
  56. /* work around some libPW problems */
  57. #define fatal Myfatal
  58. #ifdef DOINIT
  59. char Error[1];
  60. #endif
  61.  
  62. /* define this once if either system, instead of cluttering up the src */
  63. #if defined(MSDOS) || defined(atarist)
  64. #define DOSISH 1
  65. #endif
  66.  
  67. #ifdef DOSISH
  68. /* This stuff now in the MS-DOS config.h file. */
  69. #else /* !MSDOS */
  70.  
  71. /*
  72.  * The following symbols are defined if your operating system supports
  73.  * functions by that name.  All Unixes I know of support them, thus they
  74.  * are not checked by the configuration script, but are directly defined
  75.  * here.
  76.  */
  77. #define HAS_ALARM
  78. #define HAS_CHOWN
  79. #ifndef AMIGA
  80. #define HAS_CHROOT
  81. #define HAS_FORK
  82. #endif
  83. #define HAS_GETLOGIN
  84. #define HAS_GETPPID
  85. #define HAS_KILL
  86. #define HAS_LINK
  87. #define HAS_PIPE
  88. #define HAS_WAIT
  89. #define HAS_UMASK
  90. /*
  91.  * The following symbols are defined if your operating system supports
  92.  * password and group functions in general.  All Unix systems do.
  93.  */
  94. #ifndef AMIGA
  95. #define HAS_GROUP
  96. #define HAS_PASSWD
  97. #endif
  98.  
  99. #endif /* !MSDOS */
  100.  
  101. #if defined(__STDC__) || defined(_AIX) || defined(__stdc__)
  102. # define STANDARD_C 1
  103. #endif
  104.  
  105. #if defined(HASVOLATILE) || defined(STANDARD_C)
  106. #define VOLATILE volatile
  107. #else
  108. #define VOLATILE
  109. #endif
  110.  
  111. #ifdef IAMSUID
  112. #   ifndef TAINT
  113. #    define TAINT
  114. #   endif
  115. #endif
  116.  
  117. #ifndef HAS_VFORK
  118. #   define vfork fork
  119. #endif
  120.  
  121. #ifdef HAS_GETPGRP2
  122. #   ifndef HAS_GETPGRP
  123. #    define HAS_GETPGRP
  124. #   endif
  125. #   define getpgrp getpgrp2
  126. #endif
  127.  
  128. #ifdef HAS_SETPGRP2
  129. #   ifndef HAS_SETPGRP
  130. #    define HAS_SETPGRP
  131. #   endif
  132. #   define setpgrp setpgrp2
  133. #endif
  134.  
  135. #include <stdio.h>
  136. #include <ctype.h>
  137. #include <setjmp.h>
  138. #ifndef MSDOS
  139. #ifdef PARAM_NEEDS_TYPES
  140. #include <sys/types.h>
  141. #endif
  142. #include <sys/param.h>
  143. #endif
  144. #ifdef STANDARD_C
  145. /* Use all the "standard" definitions */
  146. #include <stdlib.h>
  147. #include <string.h>
  148. #define MEM_SIZE size_t
  149. #else
  150. typedef unsigned int MEM_SIZE;
  151. #endif /* STANDARD_C */
  152.  
  153. #if defined(HAS_MEMCMP) && defined(mips) && defined(ultrix)
  154. #undef HAS_MEMCMP
  155. #endif
  156.  
  157. #ifdef HAS_MEMCPY
  158. #  ifndef STANDARD_C
  159. #    ifndef memcpy
  160.     extern char * memcpy();
  161. #    endif
  162. #  endif
  163. #else
  164. #   ifndef memcpy
  165. #    ifdef HAS_BCOPY
  166. #        define memcpy(d,s,l) bcopy(s,d,l)
  167. #    else
  168. #        define memcpy(d,s,l) my_bcopy(s,d,l)
  169. #    endif
  170. #   endif
  171. #endif /* HAS_MEMCPY */
  172.  
  173. #ifdef HAS_MEMSET
  174. #  ifndef STANDARD_C
  175. #    ifndef memset
  176.     extern char *memset();
  177. #    endif
  178. #  endif
  179. #  define memzero(d,l) memset(d,0,l)
  180. #else
  181. #   ifndef memzero
  182. #    ifdef HAS_BZERO
  183. #        define memzero(d,l) bzero(d,l)
  184. #    else
  185. #        define memzero(d,l) my_bzero(d,l)
  186. #    endif
  187. #   endif
  188. #endif /* HAS_MEMSET */
  189.  
  190. #ifdef HAS_MEMCMP
  191. #  ifndef STANDARD_C
  192. #    ifndef memcmp
  193.     extern int memcmp();
  194. #    endif
  195. #  endif
  196. #else
  197. #   ifndef memcmp
  198. #    define memcmp(s1,s2,l) my_memcmp(s1,s2,l)
  199. #   endif
  200. #endif /* HAS_MEMCMP */
  201.  
  202. /* we prefer bcmp slightly for comparisons that don't care about ordering */
  203. #ifndef HAS_BCMP
  204. #   ifndef bcmp
  205. #    define bcmp(s1,s2,l) memcmp(s1,s2,l)
  206. #   endif
  207. #endif /* HAS_BCMP */
  208.  
  209. #ifndef HAS_MEMMOVE
  210. #if defined(HAS_BCOPY) && defined(SAFE_BCOPY)
  211. #define memmove(d,s,l) bcopy(s,d,l)
  212. #else
  213. #if defined(HAS_MEMCPY) && defined(SAFE_MEMCPY)
  214. #define memmove(d,s,l) memcpy(d,s,l)
  215. #else
  216. #define memmove(d,s,l) my_bcopy(s,d,l)
  217. #endif
  218. #endif
  219. #endif
  220.  
  221. #ifndef _TYPES_        /* If types.h defines this it's easy. */
  222. #ifndef major        /* Does everyone's types.h define this? */
  223. #include <sys/types.h>
  224. #endif
  225. #endif
  226.  
  227. #ifdef I_NETINET_IN
  228. #include <netinet/in.h>
  229. #endif
  230.  
  231. #include <sys/stat.h>
  232. #if defined(uts) || defined(UTekV)
  233. #undef S_ISDIR
  234. #undef S_ISCHR
  235. #undef S_ISBLK
  236. #undef S_ISREG
  237. #undef S_ISFIFO
  238. #undef S_ISLNK
  239. #define S_ISDIR(P) (((P)&S_IFMT)==S_IFDIR)
  240. #define S_ISCHR(P) (((P)&S_IFMT)==S_IFCHR)
  241. #define S_ISBLK(P) (((P)&S_IFMT)==S_IFBLK)
  242. #define S_ISREG(P) (((P)&S_IFMT)==S_IFREG)
  243. #define S_ISFIFO(P) (((P)&S_IFMT)==S_IFIFO)
  244. #ifdef S_IFLNK
  245. #define S_ISLNK(P) (((P)&S_IFMT)==S_IFLNK)
  246. #endif
  247. #endif
  248.  
  249. #ifdef I_TIME
  250. #   include <time.h>
  251. #endif
  252.  
  253. #ifdef I_SYS_TIME
  254. #   ifdef SYSTIMEKERNEL
  255. #    define KERNEL
  256. #   endif
  257. #   include <sys/time.h>
  258. #   ifdef SYSTIMEKERNEL
  259. #    undef KERNEL
  260. #   endif
  261. #endif
  262.  
  263. #ifndef MSDOS
  264. #include <sys/times.h>
  265. #endif
  266.  
  267. #if defined(HAS_STRERROR) && (!defined(HAS_MKDIR) || !defined(HAS_RMDIR))
  268. #undef HAS_STRERROR
  269. #endif
  270.  
  271. #include <errno.h>
  272. #ifndef MSDOS
  273. #ifndef errno
  274. extern int errno;     /* ANSI allows errno to be an lvalue expr */
  275. #endif
  276. #endif
  277.  
  278. #ifndef strerror
  279. #ifdef HAS_STRERROR
  280. char *strerror();
  281. #else
  282. extern int sys_nerr;
  283. extern char *sys_errlist[];
  284. #define strerror(e) ((e) < 0 || (e) >= sys_nerr ? "(unknown)" : sys_errlist[e])
  285. #endif
  286. #endif
  287.  
  288. #ifdef I_SYSIOCTL
  289. #ifndef _IOCTL_
  290. #include <sys/ioctl.h>
  291. #endif
  292. #endif
  293.  
  294. #if defined(mc300) || defined(mc500) || defined(mc700) || defined(mc6000)
  295. #ifdef HAS_SOCKETPAIR
  296. #undef HAS_SOCKETPAIR
  297. #endif
  298. #ifdef HAS_NDBM
  299. #undef HAS_NDBM
  300. #endif
  301. #endif
  302.  
  303. #ifdef WANT_DBZ
  304. #include <dbz.h>
  305. #define SOME_DBM
  306. #define dbm_fetch(db,dkey) fetch(dkey)
  307. #define dbm_delete(db,dkey) fatal("dbz doesn't implement delete")
  308. #define dbm_store(db,dkey,dcontent,flags) store(dkey,dcontent)
  309. #define dbm_close(db) dbmclose()
  310. #define dbm_firstkey(db) (fatal("dbz doesn't implement traversal"),fetch())
  311. #define nextkey() (fatal("dbz doesn't implement traversal"),fetch())
  312. #define dbm_nextkey(db) (fatal("dbz doesn't implement traversal"),fetch())
  313. #ifdef HAS_NDBM
  314. #undef HAS_NDBM
  315. #endif
  316. #ifndef HAS_ODBM
  317. #define HAS_ODBM
  318. #endif
  319. #else
  320. #ifdef HAS_GDBM
  321. #ifdef I_GDBM
  322. #include <gdbm.h>
  323. #endif
  324. #define SOME_DBM
  325. #ifdef HAS_NDBM
  326. #undef HAS_NDBM
  327. #endif
  328. #ifdef HAS_ODBM
  329. #undef HAS_ODBM
  330. #endif
  331. #else
  332. #ifdef HAS_NDBM
  333. #include <ndbm.h>
  334. #define SOME_DBM
  335. #ifdef HAS_ODBM
  336. #undef HAS_ODBM
  337. #endif
  338. #else
  339. #ifdef HAS_ODBM
  340. #ifdef NULL
  341. #undef NULL        /* suppress redefinition message */
  342. #endif
  343. #include <dbm.h>
  344. #ifdef NULL
  345. #undef NULL
  346. #endif
  347. #define NULL 0        /* silly thing is, we don't even use this */
  348. #define SOME_DBM
  349. #define dbm_fetch(db,dkey) fetch(dkey)
  350. #define dbm_delete(db,dkey) delete(dkey)
  351. #define dbm_store(db,dkey,dcontent,flags) store(dkey,dcontent)
  352. #define dbm_close(db) dbmclose()
  353. #define dbm_firstkey(db) firstkey()
  354. #endif /* HAS_ODBM */
  355. #endif /* HAS_NDBM */
  356. #endif /* HAS_GDBM */
  357. #endif /* WANT_DBZ */
  358. #ifdef SOME_DBM
  359. EXT char *dbmkey;
  360. EXT int dbmlen;
  361. #endif
  362.  
  363. #if INTSIZE == 2
  364. #define htoni htons
  365. #define ntohi ntohs
  366. #else
  367. #define htoni htonl
  368. #define ntohi ntohl
  369. #endif
  370.  
  371. #if defined(I_DIRENT)
  372. #   include <dirent.h>
  373. #   define DIRENT dirent
  374. #else
  375. #   ifdef I_SYS_NDIR
  376. #    include <sys/ndir.h>
  377. #    define DIRENT direct
  378. #   else
  379. #    ifdef I_SYS_DIR
  380. #        ifdef hp9000s500
  381. #        include <ndir.h>    /* may be wrong in the future */
  382. #        else
  383. #        include <sys/dir.h>
  384. #        endif
  385. #        define DIRENT direct
  386. #    endif
  387. #   endif
  388. #endif
  389.  
  390. #ifdef FPUTS_BOTCH
  391. /* work around botch in SunOS 4.0.1 and 4.0.2 */
  392. #   ifndef fputs
  393. #    define fputs(str,fp) fprintf(fp,"%s",str)
  394. #   endif
  395. #endif
  396.  
  397. /*
  398.  * The following gobbledygook brought to you on behalf of __STDC__.
  399.  * (I could just use #ifndef __STDC__, but this is more bulletproof
  400.  * in the face of half-implementations.)
  401.  */
  402.  
  403. #ifndef S_IFMT
  404. #   ifdef _S_IFMT
  405. #    define S_IFMT _S_IFMT
  406. #   else
  407. #    define S_IFMT 0170000
  408. #   endif
  409. #endif
  410.  
  411. #ifndef S_ISDIR
  412. #   define S_ISDIR(m) ((m & S_IFMT) == S_IFDIR)
  413. #endif
  414.  
  415. #ifndef S_ISCHR
  416. #   define S_ISCHR(m) ((m & S_IFMT) == S_IFCHR)
  417. #endif
  418.  
  419. #ifndef S_ISBLK
  420. #   ifdef S_IFBLK
  421. #    define S_ISBLK(m) ((m & S_IFMT) == S_IFBLK)
  422. #   else
  423. #    define S_ISBLK(m) (0)
  424. #   endif
  425. #endif
  426.  
  427. #ifndef S_ISREG
  428. #   define S_ISREG(m) ((m & S_IFMT) == S_IFREG)
  429. #endif
  430.  
  431. #ifndef S_ISFIFO
  432. #   ifdef S_IFIFO
  433. #    define S_ISFIFO(m) ((m & S_IFMT) == S_IFIFO)
  434. #   else
  435. #    define S_ISFIFO(m) (0)
  436. #   endif
  437. #endif
  438.  
  439. #ifndef S_ISLNK
  440. #   ifdef _S_ISLNK
  441. #    define S_ISLNK(m) _S_ISLNK(m)
  442. #   else
  443. #    ifdef _S_IFLNK
  444. #        define S_ISLNK(m) ((m & S_IFMT) == _S_IFLNK)
  445. #    else
  446. #        ifdef S_IFLNK
  447. #        define S_ISLNK(m) ((m & S_IFMT) == S_IFLNK)
  448. #        else
  449. #        define S_ISLNK(m) (0)
  450. #        endif
  451. #    endif
  452. #   endif
  453. #endif
  454.  
  455. #ifndef S_ISSOCK
  456. #   ifdef _S_ISSOCK
  457. #    define S_ISSOCK(m) _S_ISSOCK(m)
  458. #   else
  459. #    ifdef _S_IFSOCK
  460. #        define S_ISSOCK(m) ((m & S_IFMT) == _S_IFSOCK)
  461. #    else
  462. #        ifdef S_IFSOCK
  463. #        define S_ISSOCK(m) ((m & S_IFMT) == S_IFSOCK)
  464. #        else
  465. #        define S_ISSOCK(m) (0)
  466. #        endif
  467. #    endif
  468. #   endif
  469. #endif
  470.  
  471. #ifndef S_IRUSR
  472. #   ifdef S_IREAD
  473. #    define S_IRUSR S_IREAD
  474. #    define S_IWUSR S_IWRITE
  475. #    define S_IXUSR S_IEXEC
  476. #   else
  477. #    define S_IRUSR 0400
  478. #    define S_IWUSR 0200
  479. #    define S_IXUSR 0100
  480. #   endif
  481. #   define S_IRGRP (S_IRUSR>>3)
  482. #   define S_IWGRP (S_IWUSR>>3)
  483. #   define S_IXGRP (S_IXUSR>>3)
  484. #   define S_IROTH (S_IRUSR>>6)
  485. #   define S_IWOTH (S_IWUSR>>6)
  486. #   define S_IXOTH (S_IXUSR>>6)
  487. #endif
  488.  
  489. #ifndef S_ISUID
  490. #   define S_ISUID 04000
  491. #endif
  492.  
  493. #ifndef S_ISGID
  494. #   define S_ISGID 02000
  495. #endif
  496.  
  497. #ifdef f_next
  498. #undef f_next
  499. #endif
  500.  
  501. #if defined(cray) || defined(gould) || defined(i860)
  502. #   define SLOPPYDIVIDE
  503. #endif
  504.  
  505. #if defined(cray) || defined(convex) || defined (uts) || BYTEORDER > 0xffff
  506. #   define QUAD
  507. #endif
  508.  
  509. #ifdef QUAD
  510. #   ifdef cray
  511. #    define quad int
  512. #   else
  513. #    if defined(convex) || defined (uts)
  514. #        define quad long long
  515. #    else
  516. #        define quad long
  517. #    endif
  518. #   endif
  519. #endif
  520.  
  521. typedef MEM_SIZE STRLEN;
  522.  
  523. typedef struct arg ARG;
  524. typedef struct cmd CMD;
  525. typedef struct formcmd FCMD;
  526. typedef struct scanpat SPAT;
  527. typedef struct stio STIO;
  528. typedef struct sub SUBR;
  529. typedef struct string STR;
  530. typedef struct atbl ARRAY;
  531. typedef struct htbl HASH;
  532. typedef struct regexp REGEXP;
  533. typedef struct stabptrs STBP;
  534. typedef struct stab STAB;
  535. typedef struct callsave CSV;
  536.  
  537. #include "handy.h"
  538. #include "regexp.h"
  539. #include "str.h"
  540. #include "util.h"
  541. #include "form.h"
  542. #include "stab.h"
  543. #include "spat.h"
  544. #include "arg.h"
  545. #include "cmd.h"
  546. #include "array.h"
  547. #include "hash.h"
  548.  
  549. #if defined(iAPX286) || defined(M_I286) || defined(I80286)
  550. #   define I286
  551. #endif
  552.  
  553. #ifndef    STANDARD_C
  554. #ifdef CHARSPRINTF
  555.     char *sprintf();
  556. #else
  557.     int sprintf();
  558. #endif
  559. #endif
  560.  
  561. EXT char *Yes INIT("1");
  562. EXT char *No INIT("");
  563.  
  564. /* "gimme" values */
  565.  
  566. /* Note: cmd.c assumes that it can use && to produce one of these values! */
  567. #define G_SCALAR 0
  568. #define G_ARRAY 1
  569.  
  570. #ifdef CRIPPLED_CC
  571. int str_true();
  572. #else /* !CRIPPLED_CC */
  573. #define str_true(str) (Str = (str), \
  574.     (Str->str_pok ? \
  575.         ((*Str->str_ptr > '0' || \
  576.           Str->str_cur > 1 || \
  577.           (Str->str_cur && *Str->str_ptr != '0')) ? 1 : 0) \
  578.     : \
  579.         (Str->str_nok ? (Str->str_u.str_nval != 0.0) : 0 ) ))
  580. #endif /* CRIPPLED_CC */
  581.  
  582. #ifdef DEBUGGING
  583. #define str_peek(str) (Str = (str), \
  584.     (Str->str_pok ? \
  585.         Str->str_ptr : \
  586.         (Str->str_nok ? \
  587.         (sprintf(tokenbuf,"num(%g)",Str->str_u.str_nval), \
  588.             (char*)tokenbuf) : \
  589.         "" )))
  590. #endif
  591.  
  592. #ifdef CRIPPLED_CC
  593. char *str_get();
  594. #else
  595. #ifdef TAINT
  596. #define str_get(str) (Str = (str), tainted |= Str->str_tainted, \
  597.     (Str->str_pok ? Str->str_ptr : str_2ptr(Str)))
  598. #else
  599. #define str_get(str) (Str = (str), (Str->str_pok ? Str->str_ptr : str_2ptr(Str)))
  600. #endif /* TAINT */
  601. #endif /* CRIPPLED_CC */
  602.  
  603. #ifdef CRIPPLED_CC
  604. double str_gnum();
  605. #else /* !CRIPPLED_CC */
  606. #ifdef TAINT
  607. #define str_gnum(str) (Str = (str), tainted |= Str->str_tainted, \
  608.     (Str->str_nok ? Str->str_u.str_nval : str_2num(Str)))
  609. #else /* !TAINT */
  610. #define str_gnum(str) (Str = (str), (Str->str_nok ? Str->str_u.str_nval : str_2num(Str)))
  611. #endif /* TAINT*/
  612. #endif /* CRIPPLED_CC */
  613. EXT STR *Str;
  614.  
  615. #define GROWSTR(pp,lp,len) if (*(lp) < (len)) growstr(pp,lp,len)
  616.  
  617. #ifndef DOSISH
  618. #define STR_GROW(str,len) if ((str)->str_len < (len)) str_grow(str,len)
  619. #define Str_Grow str_grow
  620. #else
  621. /* extra parentheses intentionally NOT placed around "len"! */
  622. #define STR_GROW(str,len) if ((str)->str_len < (unsigned long)len) \
  623.         str_grow(str,(unsigned long)len)
  624. #define Str_Grow(str,len) str_grow(str,(unsigned long)(len))
  625. #endif /* DOSISH */
  626.  
  627. #ifndef BYTEORDER
  628. #define BYTEORDER 0x1234
  629. #endif
  630.  
  631. #if defined(htonl) && !defined(HAS_HTONL)
  632. #define HAS_HTONL
  633. #endif
  634. #if defined(htons) && !defined(HAS_HTONS)
  635. #define HAS_HTONS
  636. #endif
  637. #if defined(ntohl) && !defined(HAS_NTOHL)
  638. #define HAS_NTOHL
  639. #endif
  640. #if defined(ntohs) && !defined(HAS_NTOHS)
  641. #define HAS_NTOHS
  642. #endif
  643. #ifndef HAS_HTONL
  644. #if (BYTEORDER & 0xffff) != 0x4321
  645. #define HAS_HTONS
  646. #define HAS_HTONL
  647. #define HAS_NTOHS
  648. #define HAS_NTOHL
  649. #define MYSWAP
  650. #define htons my_swap
  651. #define htonl my_htonl
  652. #define ntohs my_swap
  653. #define ntohl my_ntohl
  654. #endif
  655. #else
  656. #if (BYTEORDER & 0xffff) == 0x4321
  657. #undef HAS_HTONS
  658. #undef HAS_HTONL
  659. #undef HAS_NTOHS
  660. #undef HAS_NTOHL
  661. #endif
  662. #endif
  663.  
  664. /*
  665.  * Little-endian byte order functions - 'v' for 'VAX', or 'reVerse'.
  666.  * -DWS
  667.  */
  668. #if BYTEORDER != 0x1234
  669. # define HAS_VTOHL
  670. # define HAS_VTOHS
  671. # define HAS_HTOVL
  672. # define HAS_HTOVS
  673. # if BYTEORDER == 0x4321
  674. #  define vtohl(x)    ((((x)&0xFF)<<24)    \
  675.             +(((x)>>24)&0xFF)    \
  676.             +(((x)&0x0000FF00)<<8)    \
  677.             +(((x)&0x00FF0000)>>8)    )
  678. #  define vtohs(x)    ((((x)&0xFF)<<8) + (((x)>>8)&0xFF))
  679. #  define htovl(x)    vtohl(x)
  680. #  define htovs(x)    vtohs(x)
  681. # endif
  682.     /* otherwise default to functions in util.c */
  683. #endif
  684.  
  685. #ifdef CASTNEGFLOAT
  686. #define U_S(what) ((unsigned short)(what))
  687. #define U_I(what) ((unsigned int)(what))
  688. #define U_L(what) ((unsigned long)(what))
  689. #else
  690. unsigned long castulong();
  691. #define U_S(what) ((unsigned int)castulong(what))
  692. #define U_I(what) ((unsigned int)castulong(what))
  693. #define U_L(what) (castulong(what))
  694. #endif
  695.  
  696. CMD *add_label();
  697. CMD *block_head();
  698. CMD *append_line();
  699. CMD *make_acmd();
  700. CMD *make_ccmd();
  701. CMD *make_icmd();
  702. CMD *invert();
  703. CMD *addcond();
  704. CMD *addloop();
  705. CMD *wopt();
  706. CMD *over();
  707.  
  708. STAB *stabent();
  709. STAB *genstab();
  710.  
  711. ARG *stab2arg();
  712. ARG *op_new();
  713. ARG *make_op();
  714. ARG *make_match();
  715. ARG *make_split();
  716. ARG *rcatmaybe();
  717. ARG *listish();
  718. ARG *maybelistish();
  719. ARG *localize();
  720. ARG *fixeval();
  721. ARG *jmaybe();
  722. ARG *l();
  723. ARG *fixl();
  724. ARG *mod_match();
  725. ARG *make_list();
  726. ARG *cmd_to_arg();
  727. ARG *addflags();
  728. ARG *hide_ary();
  729. ARG *cval_to_arg();
  730.  
  731. STR *str_new();
  732. STR *stab_str();
  733.  
  734. int apply();
  735. int do_each();
  736. int do_subr();
  737. int do_match();
  738. int do_unpack();
  739. int eval();        /* this evaluates expressions */
  740. int do_eval();        /* this evaluates eval operator */
  741. int do_assign();
  742.  
  743. SUBR *make_sub();
  744.  
  745. FCMD *load_format();
  746.  
  747. char *scanpat();
  748. char *scansubst();
  749. char *scantrans();
  750. char *scanstr();
  751. char *scanident();
  752. char *str_append_till();
  753. char *str_gets();
  754. char *str_grow();
  755.  
  756. bool do_open();
  757. bool do_close();
  758. bool do_print();
  759. bool do_aprint();
  760. bool do_exec();
  761. bool do_aexec();
  762.  
  763. int do_subst();
  764. int cando();
  765. int ingroup();
  766. int whichsig();
  767. int userinit();
  768. #ifdef CRYPTSCRIPT
  769. void cryptswitch();
  770. #endif
  771.  
  772. void str_replace();
  773. void str_inc();
  774. void str_dec();
  775. void str_free();
  776. void cmd_free();
  777. void arg_free();
  778. void spat_free();
  779. void regfree();
  780. void stab_clear();
  781. void do_chop();
  782. void do_vop();
  783. void do_write();
  784. void do_join();
  785. void do_sprintf();
  786. void do_accept();
  787. void do_pipe();
  788. void do_vecset();
  789. void do_unshift();
  790. void do_execfree();
  791. void magicalize();
  792. void magicname();
  793. void savelist();
  794. void saveitem();
  795. void saveint();
  796. void savelong();
  797. void savesptr();
  798. void savehptr();
  799. void restorelist();
  800. void repeatcpy();
  801. void make_form();
  802. void dehoist();
  803. void format();
  804. void my_unexec();
  805. void fatal();
  806. void warn();
  807. #ifdef DEBUGGING
  808. void dump_all();
  809. void dump_cmd();
  810. void dump_arg();
  811. void dump_flags();
  812. void dump_stab();
  813. void dump_spat();
  814. #endif
  815. #ifdef MSTATS
  816. void mstats();
  817. #endif
  818.  
  819. HASH *savehash();
  820. ARRAY *saveary();
  821.  
  822. EXT char **origargv;
  823. EXT int origargc;
  824. EXT char **origenviron;
  825. extern char **environ;
  826.  
  827. EXT long subline INIT(0);
  828. EXT STR *subname INIT(Nullstr);
  829. EXT int arybase INIT(0);
  830.  
  831. struct outrec {
  832.     long    o_lines;
  833.     char    *o_str;
  834.     int        o_len;
  835. };
  836.  
  837. EXT struct outrec outrec;
  838. EXT struct outrec toprec;
  839.  
  840. EXT STAB *stdinstab INIT(Nullstab);
  841. EXT STAB *last_in_stab INIT(Nullstab);
  842. EXT STAB *defstab INIT(Nullstab);
  843. EXT STAB *argvstab INIT(Nullstab);
  844. EXT STAB *envstab INIT(Nullstab);
  845. EXT STAB *sigstab INIT(Nullstab);
  846. EXT STAB *defoutstab INIT(Nullstab);
  847. EXT STAB *curoutstab INIT(Nullstab);
  848. EXT STAB *argvoutstab INIT(Nullstab);
  849. EXT STAB *incstab INIT(Nullstab);
  850. EXT STAB *leftstab INIT(Nullstab);
  851. EXT STAB *amperstab INIT(Nullstab);
  852. EXT STAB *rightstab INIT(Nullstab);
  853. EXT STAB *DBstab INIT(Nullstab);
  854. EXT STAB *DBline INIT(Nullstab);
  855. EXT STAB *DBsub INIT(Nullstab);
  856.  
  857. EXT HASH *defstash;        /* main symbol table */
  858. EXT HASH *curstash;        /* symbol table for current package */
  859. EXT HASH *debstash;        /* symbol table for perldb package */
  860.  
  861. EXT STR *curstname;        /* name of current package */
  862.  
  863. EXT STR *freestrroot INIT(Nullstr);
  864. EXT STR *lastretstr INIT(Nullstr);
  865. EXT STR *DBsingle INIT(Nullstr);
  866. EXT STR *DBtrace INIT(Nullstr);
  867. EXT STR *DBsignal INIT(Nullstr);
  868. EXT STR *formfeed INIT(Nullstr);
  869.  
  870. EXT int lastspbase;
  871. EXT int lastsize;
  872.  
  873. EXT char *hexdigit INIT("0123456789abcdef0123456789ABCDEFx");
  874. EXT char *origfilename;
  875. EXT FILE * VOLATILE rsfp;
  876. EXT char buf[1024];
  877. EXT char *bufptr;
  878. EXT char *oldbufptr;
  879. EXT char *oldoldbufptr;
  880. EXT char *bufend;
  881.  
  882. EXT STR *linestr INIT(Nullstr);
  883.  
  884. EXT char *rs INIT("\n");
  885. EXT int rschar INIT('\n');    /* final char of rs, or 0777 if none */
  886. EXT int rslen INIT(1);
  887. EXT bool rspara INIT(FALSE);
  888. EXT char *ofs INIT(Nullch);
  889. EXT int ofslen INIT(0);
  890. EXT char *ors INIT(Nullch);
  891. EXT int orslen INIT(0);
  892. EXT char *ofmt INIT(Nullch);
  893. EXT char *inplace INIT(Nullch);
  894. EXT char *nointrp INIT("");
  895.  
  896. EXT bool preprocess INIT(FALSE);
  897. EXT bool minus_n INIT(FALSE);
  898. EXT bool minus_p INIT(FALSE);
  899. EXT bool minus_l INIT(FALSE);
  900. EXT bool minus_a INIT(FALSE);
  901. EXT bool doswitches INIT(FALSE);
  902. EXT bool dowarn INIT(FALSE);
  903. EXT bool doextract INIT(FALSE);
  904. EXT bool allstabs INIT(FALSE);    /* init all customary symbols in symbol table?*/
  905. EXT bool sawampersand INIT(FALSE);    /* must save all match strings */
  906. EXT bool sawstudy INIT(FALSE);        /* do fbminstr on all strings */
  907. EXT bool sawi INIT(FALSE);        /* study must assume case insensitive */
  908. EXT bool sawvec INIT(FALSE);
  909. EXT bool localizing INIT(FALSE);    /* are we processing a local() list? */
  910.  
  911. #ifndef MAXSYSFD
  912. #   define MAXSYSFD 2
  913. #endif
  914. EXT int maxsysfd INIT(MAXSYSFD);    /* top fd to pass to subprocesses */
  915.  
  916. #ifdef CSH
  917. EXT char *cshname INIT(CSH);
  918. EXT int cshlen INIT(0);
  919. #endif /* CSH */
  920.  
  921. #ifdef TAINT
  922. EXT bool tainted INIT(FALSE);        /* using variables controlled by $< */
  923. EXT bool taintanyway INIT(FALSE);    /* force taint checks when !set?id */
  924. #endif
  925.  
  926. EXT bool nomemok INIT(FALSE);        /* let malloc context handle nomem */
  927.  
  928. #ifndef DOSISH
  929. #define TMPPATH "/tmp/perl-eXXXXXX"
  930. #else
  931. #define TMPPATH "plXXXXXX"
  932. #endif /* MSDOS */
  933. EXT char *e_tmpname;
  934. EXT FILE *e_fp INIT(Nullfp);
  935.  
  936. EXT char tokenbuf[256];
  937. EXT int expectterm INIT(TRUE);        /* how to interpret ambiguous tokens */
  938. EXT VOLATILE int in_eval INIT(FALSE);    /* trap fatal errors? */
  939. EXT int multiline INIT(0);        /* $*--do strings hold >1 line? */
  940. EXT int forkprocess;            /* so do_open |- can return proc# */
  941. EXT int do_undump INIT(0);        /* -u or dump seen? */
  942. EXT int error_count INIT(0);        /* how many errors so far, max 10 */
  943. EXT int multi_start INIT(0);        /* 1st line of multi-line string */
  944. EXT int multi_end INIT(0);        /* last line of multi-line string */
  945. EXT int multi_open INIT(0);        /* delimiter of said string */
  946. EXT int multi_close INIT(0);        /* delimiter of said string */
  947.  
  948. FILE *popen();
  949. /* char *str_get(); */
  950. STR *interp();
  951. void free_arg();
  952. STIO *stio_new();
  953. void hoistmust();
  954. void scanconst();
  955.  
  956. EXT struct stat statbuf;
  957. EXT struct stat statcache;
  958. EXT STAB *statstab INIT(Nullstab);
  959. EXT STR *statname;
  960. #ifndef MSDOS
  961. EXT struct tms timesbuf;
  962. #endif
  963. EXT int uid;
  964. EXT int euid;
  965. EXT int gid;
  966. EXT int egid;
  967. UIDTYPE getuid();
  968. UIDTYPE geteuid();
  969. GIDTYPE getgid();
  970. GIDTYPE getegid();
  971. EXT int unsafe;
  972.  
  973. #ifdef DEBUGGING
  974. EXT VOLATILE int debug INIT(0);
  975. EXT int dlevel INIT(0);
  976. EXT int dlmax INIT(128);
  977. EXT char *debname;
  978. EXT char *debdelim;
  979. #define YYDEBUG 1
  980. #endif
  981. EXT int perldb INIT(0);
  982. #define YYMAXDEPTH 300
  983.  
  984. EXT line_t cmdline INIT(NOLINE);
  985.  
  986. EXT STR str_undef;
  987. EXT STR str_no;
  988. EXT STR str_yes;
  989.  
  990. /* runtime control stuff */
  991.  
  992. EXT struct loop {
  993.     char *loop_label;        /* what the loop was called, if anything */
  994.     int loop_sp;        /* stack pointer to copy stuff down to */
  995.     jmp_buf loop_env;
  996. } *loop_stack;
  997.  
  998. EXT int loop_ptr INIT(-1);
  999. EXT int loop_max INIT(128);
  1000.  
  1001. EXT jmp_buf top_env;
  1002.  
  1003. EXT char * VOLATILE goto_targ INIT(Nullch); /* cmd_exec gets strange when set */
  1004.  
  1005. struct ufuncs {
  1006.     int (*uf_val)();
  1007.     int (*uf_set)();
  1008.     int uf_index;
  1009. };
  1010.  
  1011. EXT ARRAY *stack;        /* THE STACK */
  1012.  
  1013. EXT ARRAY * VOLATILE savestack;        /* to save non-local values on */
  1014.  
  1015. EXT ARRAY *tosave;        /* strings to save on recursive subroutine */
  1016.  
  1017. EXT ARRAY *lineary;        /* lines of script for debugger */
  1018. EXT ARRAY *dbargs;        /* args to call listed by caller function */
  1019.  
  1020. EXT ARRAY *fdpid;        /* keep fd-to-pid mappings for mypopen */
  1021. EXT HASH *pidstatus;        /* keep pid-to-status mappings for waitpid */
  1022.  
  1023. EXT int *di;            /* for tmp use in debuggers */
  1024. EXT char *dc;
  1025. EXT short *ds;
  1026.  
  1027. /* Fix these up for __STDC__ */
  1028. EXT time_t basetime INIT(0);
  1029. char *mktemp();
  1030. #ifndef STANDARD_C
  1031. /* All of these are in stdlib.h or time.h for ANSI C */
  1032. double atof();
  1033. long time();
  1034. struct tm *gmtime(), *localtime();
  1035. char *index(), *rindex();
  1036. char *strcpy(), *strcat();
  1037. #endif /* ! STANDARD_C */
  1038.  
  1039. #ifdef EUNICE
  1040. #define UNLINK unlnk
  1041. int unlnk();
  1042. #else
  1043. #define UNLINK unlink
  1044. #endif
  1045.  
  1046. #ifndef HAS_SETREUID
  1047. #ifdef HAS_SETRESUID
  1048. #define setreuid(r,e) setresuid(r,e,-1)
  1049. #define HAS_SETREUID
  1050. #endif
  1051. #endif
  1052. #ifndef HAS_SETREGID
  1053. #ifdef HAS_SETRESGID
  1054. #define setregid(r,e) setresgid(r,e,-1)
  1055. #define HAS_SETREGID
  1056. #endif
  1057. #endif
  1058.  
  1059. #define SCAN_DEF 0
  1060. #define SCAN_TR 1
  1061. #define SCAN_REPL 2
  1062.  
  1063. #ifdef AMIGA
  1064. #define longjmp(a,b) _longjmp(a,b)
  1065. #define setjmp(a)    _setjmp(a)
  1066. /* #undef HAS_WAIT */
  1067. #endif
  1068.  
  1069. #ifdef AMIGA
  1070.  
  1071. #define execv(a,b) { \
  1072.    char acTmp[BUFSIZ]; \
  1073.    int i;              \
  1074.    strcpy(acTmp, (a)); \
  1075.    for(i=1; (b)[i] != NULL; i++) { \
  1076.      strcat(acTmp, " "); \
  1077.      strcat(acTmp, (b)[i]); \
  1078.    } \
  1079.    ssystem(acTmp); \
  1080.  }
  1081.  
  1082. #define execve(a,b,c) { \
  1083.    char acTmp[BUFSIZ]; \
  1084.    int i;              \
  1085.    strcpy(acTmp, (a)); \
  1086.    for(i=1; (b)[i] != NULL; i++) { \
  1087.      strcat(acTmp, " "); \
  1088.      strcat(acTmp, (b)[i]); \
  1089.    } \
  1090.    ssystem(acTmp); \
  1091.  }
  1092.  
  1093. #define execvp(a,b) { \
  1094.    char acTmp[BUFSIZ]; \
  1095.    int i;              \
  1096.    strcpy(acTmp, (a)); \
  1097.    for(i=1; (b)[i] != NULL; i++) { \
  1098.      strcat(acTmp, " "); \
  1099.      strcat(acTmp, (b)[i]); \
  1100.    } \
  1101.    ssystem(acTmp); \
  1102.  }
  1103. #endif
  1104.  
  1105. #ifdef AMIGA
  1106. /*** Default perl library path... ***/
  1107. #define PRIVLIB "/usr/lib/perl"
  1108. #endif
  1109.  
  1110.